//using System;
//using System.Collections;
//using FireStarterModeller.BO;
//using FireStarterModeller.UI;
//using Habanero.Base;
//using Habanero.BO;
//using Habanero.BO.ClassDefinition;
//using Habanero.UI.Base;
//using Habanero.UI.Win;
//using NUnit.Framework;
//using FirestarterModeller.Test.BO;

//namespace FireStarterModeller.Test.UI
//{
//    /// <summary>
//    /// TODO: - behave nicely when the deletion fails
//    /// </summary>
//    [TestFixture]
//    public class TestGridAndBOEditorControl : TestBase
//    {
//        private const string CUSTOM_UIDEF_NAME = "custom1";

//        [SetUp]
//        public override void SetupTest()
//        {
//            //Runs every time that any testmethod is executed
//            base.SetupTest();
//        }

//        [TestFixtureSetUp]
//        public void TestFixtureSetup()
//        {
//            //Code that is executed before any test is run in this class. If multiple tests
//            // are executed then it will still only be called once.
//        }

//        [TearDown]
//        public override void TearDownTest()
//        {
//            //runs every time any testmethod is complete
//            base.TearDownTest();
//        }

//        // Creates a new UI def by cloning an existing one and adding a cloned column
//        //   (easier than creating a whole new BO for this test)
//        private static ClassDef GetCustomClassDef()
//        {
//            ClassDef classDef = ClassDef.Get<BusinessObjectInfo>();
//            UIGrid originalGridDef = classDef.UIDefCol["default"].UIGrid;
//            UIGrid extraGridDef = originalGridDef.Clone();
//            //UIGridColumn extraColumn = originalGridDef[0].Clone();
//            //extraGridDef.Add(extraColumn);
//            extraGridDef.Remove(extraGridDef[extraGridDef.Count - 1]);
//            //UIGridColumn extraColumn = new UIGridColumn("ID", "ProjectAssemblyInfoID", typeof(System.Windows.Forms.DataGridViewTextBoxColumn), true, 100, UIGridColumn.PropAlignment.right, null);
//            //extraGridDef.Add(extraColumn);
//            UIDef extraUIDef = new UIDef(CUSTOM_UIDEF_NAME, null, extraGridDef);
//            classDef.UIDefCol.Add(extraUIDef);
//            return classDef;
//        }

//        private static GridAndBOEditorControl<BusinessObjectInfo> CreateGridAndBOEditorControl()
//        {
//            IBusinessObjectControlWithErrorDisplay businessObjectControl = new BusinessObjectControlStub();
//            return new GridAndBOEditorControl<BusinessObjectInfo>(GetControlFactory(), businessObjectControl);
//        }

//        private static GridAndBOEditorControl<ProjectAssemblyInfo> CreateGridAndBOEditorControl_ProjectAssemblyInfos()
//        {
//            IBusinessObjectControlWithErrorDisplay businessObjectControl = new BusinessObjectControlStub();
//            return new GridAndBOEditorControl<ProjectAssemblyInfo>(GetControlFactory(), businessObjectControl);
//        }

//        private static void AssertSelectedBusinessObject(BusinessObjectInfo businessObjectInfo, GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl)
//        {
//            Assert.AreSame(businessObjectInfo, gridAndBOEditorControl.ReadOnlyGridControl.SelectedBusinessObject);
//            Assert.AreSame(businessObjectInfo, gridAndBOEditorControl.BusinessObjectControl.BusinessObject, "Selected BO in Grid should be loaded in the BoControl");
//            Assert.AreSame(businessObjectInfo, gridAndBOEditorControl.CurrentBusinessObject);
//        }

//        private static IControlFactory GetControlFactory()
//        {
//            return GlobalUIRegistry.ControlFactory;
//        }

//        [Test]
//        public void TestConstructor_FailsIfBOControlNull()
//        {
//            //---------------Set up test pack-------------------
//            //---------------Assert Precondition----------------
//            //---------------Execute Test ----------------------
//            try
//            {
//                GridAndBOEditorControl<ProjectAssemblyInfo> gridAndBOEditorControl =
//                    new GridAndBOEditorControl<ProjectAssemblyInfo>(GetControlFactory(), (IBusinessObjectControlWithErrorDisplay) ((IBusinessObjectControlWithErrorDisplay) null));

//                Assert.Fail("Null BOControl should be prevented");
//            }
//                //---------------Test Result -----------------------
//            catch (ArgumentNullException ex)
//            {
//                Assert.AreEqual("businessObjectControl", ex.ParamName);
//            }
//            //---------------Test Result -----------------------
//        }

//        [Test]
//        public void TestConstructor_FailsIfControlFactoryNull()
//        {
//            //---------------Set up test pack-------------------
//            IBusinessObjectControlWithErrorDisplay businessObjectControl = new BusinessObjectControlStub();
//            //---------------Assert Precondition----------------

//            //---------------Execute Test ----------------------
//            try
//            {
//                GridAndBOEditorControl<ProjectAssemblyInfo> gridAndBOEditorControl =
//                    new GridAndBOEditorControl<ProjectAssemblyInfo>((IControlFactory) ((IControlFactory) null), businessObjectControl);

//                Assert.Fail("Null ControlFactory should be prevented");
//            }
//            //---------------Test Result -----------------------
//            catch (ArgumentNullException ex)
//            {
//                Assert.AreEqual("controlFactory", ex.ParamName);
//            }
//            //---------------Test Result -----------------------
//        }

//        [Test]
//        public void TestConstructor()
//        {
//            //---------------Set up test pack-------------------
//            IBusinessObjectControlWithErrorDisplay businessObjectControl = new BusinessObjectControlStub();
//            //---------------Assert Precondition----------------

//            //---------------Execute Test ----------------------
//            GridAndBOEditorControl<ProjectAssemblyInfo> gridAndBOEditorControl =
//                new GridAndBOEditorControl<ProjectAssemblyInfo>(GetControlFactory(), businessObjectControl);
//            //---------------Test Result -----------------------
//            Assert.AreEqual(3, gridAndBOEditorControl.Controls.Count);
//            Assert.IsInstanceOfType(typeof(IUserControlHabanero), gridAndBOEditorControl);
//            Assert.IsInstanceOfType(typeof(IBusinessObjectControlWithErrorDisplay), gridAndBOEditorControl.Controls[0]);
//            Assert.IsInstanceOfType(typeof(IReadOnlyGridControl), gridAndBOEditorControl.Controls[1]);
//            Assert.IsInstanceOfType(typeof(IButtonGroupControl), gridAndBOEditorControl.Controls[2]);
//            Assert.AreSame(businessObjectControl, gridAndBOEditorControl.BusinessObjectControl);
//            Assert.IsFalse(businessObjectControl.Enabled);
//        }

//        [Test]
//        public void TestConstructor_UsingCustomUIDefName()
//        {
//            //---------------Set up test pack-------------------
//            IBusinessObjectControlWithErrorDisplay businessObjectControl = new BusinessObjectControlStub();

//            ClassDef classDef = GetCustomClassDef();
//            //---------------Assert Precondition----------------

//            //---------------Execute Test ----------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl =
//                new GridAndBOEditorControl<BusinessObjectInfo>(GetControlFactory(), businessObjectControl, CUSTOM_UIDEF_NAME);
//            //---------------Test Result -----------------------
//            Assert.AreEqual(3, gridAndBOEditorControl.Controls.Count);
//            Assert.IsInstanceOfType(typeof(IUserControlHabanero), gridAndBOEditorControl);
//            Assert.IsInstanceOfType(typeof(IBusinessObjectControlWithErrorDisplay), gridAndBOEditorControl.Controls[0]);
//            Assert.IsInstanceOfType(typeof(IReadOnlyGridControl), gridAndBOEditorControl.Controls[1]);
//            Assert.IsInstanceOfType(typeof(IButtonGroupControl), gridAndBOEditorControl.Controls[2]);
//            Assert.AreSame(businessObjectControl, gridAndBOEditorControl.BusinessObjectControl);
//        }

//        [Test]
//        public void TestGridConstruction()
//        {
//            //---------------Set up test pack-------------------
//            IBusinessObjectControlWithErrorDisplay businessObjectControl = new BusinessObjectControlStub();
//            //---------------Assert Precondition----------------

//            //---------------Execute Test ----------------------
//            GridAndBOEditorControl<ProjectAssemblyInfo> gridAndBOEditorControl =
//                new GridAndBOEditorControl<ProjectAssemblyInfo>(GetControlFactory(), businessObjectControl);
//            //---------------Test Result -----------------------
//            IReadOnlyGridControl readOnlyGridControl = gridAndBOEditorControl.ReadOnlyGridControl;
//            Assert.IsNotNull(readOnlyGridControl);
//            Assert.IsFalse(readOnlyGridControl.Buttons.Visible);
//            Assert.IsFalse(readOnlyGridControl.FilterControl.Visible);
//            Assert.IsNull(readOnlyGridControl.Grid.GetBusinessObjectCollection());
//            int expectedWidth = UIUtilities.GetGridWidthToFitColumns(readOnlyGridControl.Grid) + 2;
//            Assert.AreEqual(expectedWidth, readOnlyGridControl.Width);
//        }

//        [Test]
//        public void TestGridWithCustomClassDef()
//        {
//            //---------------Set up test pack-------------------
//            ClassDef classDef = GetCustomClassDef();
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            businessObjectInfos.ClassDef = classDef;
//            IBusinessObjectControlWithErrorDisplay businessObjectControl = new BusinessObjectControlStub();

//            //---------------Assert Precondition----------------
//            Assert.IsTrue(classDef.UIDefCol.Count >= 2);
//            //---------------Execute Test ----------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl =
//                new GridAndBOEditorControl<BusinessObjectInfo>(GetControlFactory(), businessObjectControl, CUSTOM_UIDEF_NAME);
//            //---------------Test Result -----------------------
//            Assert.AreEqual(CUSTOM_UIDEF_NAME, gridAndBOEditorControl.ReadOnlyGridControl.UiDefName);
//        }

//        [Test]
//        public void TestButtonControlConstruction()
//        {
//            //---------------Set up test pack-------------------
//            IBusinessObjectControlWithErrorDisplay businessObjectControl = new BusinessObjectControlStub();
//            //---------------Assert Precondition----------------

//            //---------------Execute Test ----------------------
//            GridAndBOEditorControl<ProjectAssemblyInfo> gridAndBOEditorControl =
//                new GridAndBOEditorControl<ProjectAssemblyInfo>(GetControlFactory(), businessObjectControl);
//            //---------------Test Result -----------------------
//            IButtonGroupControl buttonGroupControl = gridAndBOEditorControl.Buttons;
//            Assert.IsNotNull(buttonGroupControl);
//            Assert.AreEqual(3, buttonGroupControl.Controls.Count);
//            Assert.AreEqual("Cancel", buttonGroupControl.Controls[0].Text);
//            Assert.AreEqual("Delete", buttonGroupControl.Controls[1].Text);
//            Assert.AreEqual("New", buttonGroupControl.Controls[2].Text);
//        }

//        [Test]
//        public void Test_SetBusinessObjectCollection_InitialSelection_NoItems()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos = new BusinessObjectCollection<BusinessObjectInfo>();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(0, businessObjectInfos.Count);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            //---------------Test Result -----------------------
//            IReadOnlyGridControl readOnlyGridControl = gridAndBOEditorControl.ReadOnlyGridControl;
//            Assert.AreEqual(businessObjectInfos.Count, readOnlyGridControl.Grid.Rows.Count);
//            AssertSelectedBusinessObject(null, gridAndBOEditorControl);
//        }

//        [Test]
//        public void Test_SetBusinessObjectCollection_FirstItemIsSelectedAndControlGetsBO()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(2, businessObjectInfos.Count);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            //---------------Test Result -----------------------
//            AssertSelectedBusinessObject(businessObjectInfos[0], gridAndBOEditorControl);
//        }

//        [Test]
//        public void Test_SelectBusinessObject_ChangesBOInBOControl()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            IReadOnlyGridControl readOnlyGridControl = gridAndBOEditorControl.ReadOnlyGridControl;
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(2, businessObjectInfos.Count);
//            AssertSelectedBusinessObject(businessObjectInfos[0], gridAndBOEditorControl);
//            //---------------Execute Test ----------------------
//            readOnlyGridControl.SelectedBusinessObject = businessObjectInfos[1];
//            //---------------Test Result -----------------------
//            AssertSelectedBusinessObject(businessObjectInfos[1], gridAndBOEditorControl);
//        }

//        [Test]
//        public void Test_SetBusinessObjectCollection()
//        {
//            //---------------Set up test pack-------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(2, businessObjectInfos.Count);
//            Assert.AreEqual(0, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            //---------------Test Result -----------------------
//            Assert.AreEqual(businessObjectInfos.Count, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.AreNotEqual(0, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Columns.Count);
//        }

//        [Test]
//        public void Test_SetBusinessObjectCollection_ToNull()
//        {
//            //---------------Set up test pack-------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(0, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            //---------------Execute Test ----------------------
//            try
//            {
//                gridAndBOEditorControl.SetBusinessObjectCollection(null);
//            //---------------Test Result -----------------------
//                Assert.Fail("Error should have been thrown");
//            }
//            catch (ArgumentNullException ex)
//            {
//                Assert.AreEqual("col", ex.ParamName );
//            }
//        }

//        [Test]
//        public void TestBOControlDisabledWhenGridIsCleared()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(2, businessObjectInfos.Count);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.SetBusinessObjectCollection(new BusinessObjectCollection<BusinessObjectInfo>());
//            //---------------Test Result -----------------------
//            Assert.AreEqual(0, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            AssertSelectedBusinessObject(null, gridAndBOEditorControl);
//            Assert.IsFalse(gridAndBOEditorControl.BusinessObjectControl.Enabled);
//        }

//        [Test]
//        public void TestBOControlEnabledWhenSelectedBOIsChanged()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(new BusinessObjectCollection<BusinessObjectInfo>());
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(2, businessObjectInfos.Count);
//            AssertSelectedBusinessObject(null, gridAndBOEditorControl);
//            Assert.IsFalse(gridAndBOEditorControl.BusinessObjectControl.Enabled);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            //---------------Test Result -----------------------
//            Assert.IsTrue(gridAndBOEditorControl.BusinessObjectControl.Enabled);
//        }

//        [Test]
//        public void TestNewButtonDisabledUntilCollectionSet()
//        {
//            //---------------Set up test pack-------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            IButton newButton = gridAndBOEditorControl.Buttons["New"];
//            //---------------Assert Precondition----------------
//            Assert.IsFalse(newButton.Enabled);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.SetBusinessObjectCollection(new BusinessObjectCollection<BusinessObjectInfo>());
//            //---------------Test Result -----------------------
//            Assert.IsTrue(newButton.Enabled);
//        }

//        [Test]
//        public void TestNewButtonClickedCreatesBO_EmptyCollection()
//        {
//            //---------------Set up test pack-------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos = new BusinessObjectCollection<BusinessObjectInfo>();
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(0, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.AreEqual(0, businessObjectInfos.Count);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.Buttons["New"].PerformClick();
//            //---------------Test Result -----------------------
//            Assert.AreEqual(1, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.AreEqual(1, businessObjectInfos.Count);
//            AssertSelectedBusinessObject(businessObjectInfos[0], gridAndBOEditorControl);
//            Assert.IsTrue(gridAndBOEditorControl.BusinessObjectControl.Enabled);
//            Assert.IsTrue(gridAndBOEditorControl.Buttons["Cancel"].Enabled);
//        }

//        [Test]
//        public void TestNewButtonClickedCreatesBO_ExistingCollection()
//        {
//            //---------------Set up test pack-------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            IFormHabanero form = GetControlFactory().CreateForm();
//            form.Controls.Add(gridAndBOEditorControl);
//            form.Show();
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(2, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.AreEqual(2, businessObjectInfos.Count);
//            Assert.IsFalse(gridAndBOEditorControl.BusinessObjectControl.Focused);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.Buttons["New"].PerformClick();
//            //---------------Test Result -----------------------
//            Assert.AreEqual(3, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.AreEqual(3, businessObjectInfos.Count);
//            Assert.IsTrue(businessObjectInfos[2].Status.IsNew);
//            AssertSelectedBusinessObject(businessObjectInfos[2], gridAndBOEditorControl);
//            Assert.IsTrue(gridAndBOEditorControl.BusinessObjectControl.Enabled);
//            Assert.IsTrue(gridAndBOEditorControl.BusinessObjectControl.Focused);
//            Assert.IsTrue(gridAndBOEditorControl.Buttons["Cancel"].Enabled);
//        }

//        [Test]
//        public void TestDeleteButtonDisabledAtConstruction()
//        {
//            //---------------Set up test pack-------------------
//            IBusinessObjectControlWithErrorDisplay businessObjectControl = new BusinessObjectControlStub();
//            //---------------Assert Precondition----------------
            
//            //---------------Execute Test ----------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = new GridAndBOEditorControl<BusinessObjectInfo>(
//                GetControlFactory(), businessObjectControl);
//            //---------------Test Result -----------------------
//            IButton deleteButton = gridAndBOEditorControl.Buttons["Delete"];
//            Assert.IsFalse(deleteButton.Enabled);
//        }

//        [Test]
//        public void TestDeleteButtonEnabledWhenBOSelected()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(new BusinessObjectCollection<BusinessObjectInfo>());
//            IButton deleteButton = gridAndBOEditorControl.Buttons["Delete"];
//            //---------------Assert Precondition----------------
//            Assert.IsFalse(deleteButton.Enabled);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            //---------------Test Result -----------------------
//            AssertSelectedBusinessObject(businessObjectInfos[0], gridAndBOEditorControl);
//            Assert.IsTrue(deleteButton.Enabled);
//        }

//        [Test]
//        public void TestDeleteButtonDisabledWhenControlHasNoBO()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            IButton deleteButton = gridAndBOEditorControl.Buttons["Delete"];
//            //---------------Assert Precondition----------------
//            Assert.IsTrue(deleteButton.Enabled);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.SetBusinessObjectCollection(new BusinessObjectCollection<BusinessObjectInfo>());
//            //---------------Test Result -----------------------
//            AssertSelectedBusinessObject(null, gridAndBOEditorControl);
//            Assert.IsFalse(deleteButton.Enabled);
//        }

//        [Test]
//        public void TestDeleteButtonDisabledWhenNewObjectAdded()
//        {
//            //---------------Set up test pack-------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(new BusinessObjectCollection<BusinessObjectInfo>());
//            IButton deleteButton = gridAndBOEditorControl.Buttons["Delete"];
//            IButton newButton = gridAndBOEditorControl.Buttons["New"];
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(0, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.IsFalse(deleteButton.Enabled);
//            //---------------Execute Test ----------------------
//            newButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.AreEqual(1, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.IsFalse(deleteButton.Enabled);
//        }

//        [Test]
//        public void TestDeleteButtonEnabledWhenOldObjectSelected()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            IButton deleteButton = gridAndBOEditorControl.Buttons["Delete"];
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(0, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.IsFalse(deleteButton.Enabled);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            //---------------Test Result -----------------------
//            Assert.AreEqual(2, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.IsTrue(deleteButton.Enabled);
//        }

//        [Test]
//        public void TestDeleteButtonDeletesCurrentBO()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            IButton deleteButton = gridAndBOEditorControl.Buttons["Delete"];
//            BusinessObjectInfo currentBO = businessObjectInfos[0];
//            //---------------Assert Precondition----------------
//            AssertSelectedBusinessObject(currentBO, gridAndBOEditorControl);
//            Assert.IsFalse(currentBO.Status.IsDeleted);
//            Assert.AreEqual(2, businessObjectInfos.Count);
//            //---------------Execute Test ----------------------
//            deleteButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.IsTrue(currentBO.Status.IsDeleted);
//            Assert.IsFalse(currentBO.Status.IsDirty);
//            Assert.AreEqual(1, businessObjectInfos.Count);
//            Assert.IsFalse(businessObjectInfos.Contains(currentBO));
//        }

//        [Test]
//        public void TestDeleteButton_ControlsUpdated()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            IButton deleteButton = gridAndBOEditorControl.Buttons["Delete"];
//            BusinessObjectInfo currentBO = businessObjectInfos[0];
//            BusinessObjectInfo otherBO = businessObjectInfos[1];
//            //---------------Assert Precondition----------------
//            AssertSelectedBusinessObject(currentBO, gridAndBOEditorControl);
//            Assert.AreEqual(2, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            //---------------Execute Test ----------------------
//            deleteButton.PerformClick();
//            //---------------Test Result -----------------------
//            AssertSelectedBusinessObject(otherBO, gridAndBOEditorControl);
//            Assert.AreEqual(1, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//        }

//        // Tests a unique set of circumstances
//        [Test]
//        public void TestDeleteSelectsPreviousRow_NewTypeNewCancelDelete()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<ProjectAssemblyInfo> projectAssemblyInfos =
//                TestUtils.CreateSavedProjectAssemblyInfosCollection();
//            GridAndBOEditorControl<ProjectAssemblyInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl_ProjectAssemblyInfos();
//            gridAndBOEditorControl.SetBusinessObjectCollection(projectAssemblyInfos);
//            IButton newButton = gridAndBOEditorControl.Buttons["New"];
//            IButton deleteButton = gridAndBOEditorControl.Buttons["Delete"];
//            IButton cancelButton = gridAndBOEditorControl.Buttons["Cancel"];
//            ProjectAssemblyInfo currentBO = gridAndBOEditorControl.CurrentBusinessObject;
//            //---------------Assert Precondition----------------
//            Assert.AreEqual(1, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            //---------------Execute Test ----------------------
//            newButton.PerformClick();
//            gridAndBOEditorControl.CurrentBusinessObject.Name = TestUtils.GetRandomString();
//            gridAndBOEditorControl.CurrentBusinessObject.ProjectInfo = projectAssemblyInfos[0].ProjectInfo;
//            newButton.PerformClick();
//            cancelButton.PerformClick();
//            deleteButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.AreEqual(1, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.AreSame(currentBO, gridAndBOEditorControl.CurrentBusinessObject);
//        }

//        [Test]
//        public void TestCancelButton_DisabledOnConstruction()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            IButton cancelButton = gridAndBOEditorControl.Buttons["Cancel"];
//            BusinessObjectInfo currentBO = businessObjectInfos[0];
//            //---------------Assert Precondition----------------
//            Assert.IsFalse(currentBO.Status.IsDirty);
//            //---------------Execute Test ----------------------
            
//            //---------------Test Result -----------------------
//            Assert.IsFalse(cancelButton.Enabled);
//        }

//        [Test]
//        public void TestCancelButton_EnabledWhenObjectEdited()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            IButton cancelButton = gridAndBOEditorControl.Buttons["Cancel"];
//            BusinessObjectInfo currentBO = businessObjectInfos[0];
//            //---------------Assert Precondition----------------
//            Assert.IsFalse(currentBO.Status.IsDirty);
//            //---------------Execute Test ----------------------
//            currentBO.BusinessObjectName = TestUtils.GetRandomString();
//            //---------------Test Result -----------------------
//            Assert.IsTrue(currentBO.Status.IsDirty);
//            Assert.IsTrue(cancelButton.Enabled);
//        }

//        [Test]
//        public void TestCancelButton_ClickRestoresSavedObject()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            IButton cancelButton = gridAndBOEditorControl.Buttons["Cancel"];
            
//            BusinessObjectInfo currentBO = businessObjectInfos[0];
//            string originalValue = currentBO.BusinessObjectName;
//            currentBO.BusinessObjectName = TestUtils.GetRandomString();
//            //---------------Assert Precondition----------------
//            Assert.IsTrue(currentBO.Status.IsDirty);
//            Assert.AreNotEqual(originalValue, currentBO.BusinessObjectName);
//            //---------------Execute Test ----------------------
//            cancelButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.IsFalse(currentBO.Status.IsDirty);
//            Assert.IsFalse(cancelButton.Enabled);
//            Assert.AreEqual(originalValue, currentBO.BusinessObjectName);
//        }

//        [Test]
//        public void TestCancelButton_ClickRemovesNewObject_OnlyItemInGrid()
//        {
//            //---------------Set up test pack-------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(new BusinessObjectCollection<BusinessObjectInfo>());
//            IButton cancelButton = gridAndBOEditorControl.Buttons["Cancel"];
//            IButton newButton = gridAndBOEditorControl.Buttons["New"];
            
//            newButton.PerformClick();
//            //---------------Assert Precondition----------------
//            Assert.IsTrue(cancelButton.Enabled);
//            Assert.AreEqual(1, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.IsTrue(gridAndBOEditorControl.BusinessObjectControl.Enabled);
//            //---------------Execute Test ----------------------
//            cancelButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.AreEqual(0, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.IsFalse(gridAndBOEditorControl.BusinessObjectControl.Enabled);
//        }

//        [Test]
//        public void TestCancelButton_ClickRemovesNewObject_TwoItemsInGrid()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            IButton cancelButton = gridAndBOEditorControl.Buttons["Cancel"];
//            IButton newButton = gridAndBOEditorControl.Buttons["New"];

//            newButton.PerformClick();
//            //---------------Assert Precondition----------------
//            Assert.IsTrue(cancelButton.Enabled);
//            Assert.AreEqual(3, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.IsTrue(gridAndBOEditorControl.BusinessObjectControl.Enabled);
//            //---------------Execute Test ----------------------
//            cancelButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.AreEqual(2, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.IsTrue(gridAndBOEditorControl.BusinessObjectControl.Enabled);
//            Assert.IsNotNull(gridAndBOEditorControl.ReadOnlyGridControl.SelectedBusinessObject);
//        }

//        [Test]
//        public void TestCancelButton_RestoreChangesGridText()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos =
//                TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            IButton cancelButton = gridAndBOEditorControl.Buttons["Cancel"];

//            BusinessObjectInfo currentBO = gridAndBOEditorControl.CurrentBusinessObject;
//            string originalValue = currentBO.BusinessObjectName;
//            string newValue = TestUtils.GetRandomString();
//            currentBO.BusinessObjectName = newValue;
//            //---------------Assert Precondition----------------
//            Assert.AreNotEqual(originalValue, newValue);
//            Assert.AreEqual(newValue, currentBO.BusinessObjectName);
//            Assert.AreEqual(newValue, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows[0].Cells["BusinessObjectName"].Value);
//            //---------------Execute Test ----------------------
//            cancelButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.AreEqual(originalValue, currentBO.BusinessObjectName);
//            Assert.AreEqual(originalValue, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows[0].Cells["BusinessObjectName"].Value);
//            Assert.AreSame(currentBO, gridAndBOEditorControl.CurrentBusinessObject);
//        }

//        [Test]
//        public void Test_ObjectSavesWhenNewButtonClicked()
//        {
//            //---------------Set up test pack-------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            BusinessObjectControlStub boControl = (BusinessObjectControlStub)gridAndBOEditorControl.BusinessObjectControl;
//            ProjectInfo projectInfo = TestUtils.CreateSavedProjectInfo();
//            gridAndBOEditorControl.SetBusinessObjectCollection(projectInfo.BusinessObjectInfos);
//            IButton newButton = gridAndBOEditorControl.Buttons["New"];
//            newButton.PerformClick();
//            BusinessObjectInfo currentBO = (BusinessObjectInfo) gridAndBOEditorControl.BusinessObjectControl.BusinessObject;
//            TestUtils.UpdateBusinessObjectWithValidData(currentBO);
//            //---------------Assert Precondition----------------
//            Assert.IsTrue(currentBO.Status.IsDirty);
//            Assert.IsTrue(currentBO.Status.IsNew);
//            Assert.IsTrue(currentBO.IsValid());
//            //---------------Execute Test ----------------------
//            newButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.AreNotSame(currentBO, gridAndBOEditorControl.BusinessObjectControl.BusinessObject);
//            Assert.IsFalse(currentBO.Status.IsDirty);
//            Assert.IsFalse(currentBO.Status.IsNew);
//            Assert.IsFalse(currentBO.Status.IsDeleted);
//            Assert.IsFalse(boControl.DisplayErrorsCalled);
//        }

//        [Test]
//        public void Test_ObjectSavesWhenGridRowChanged()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos = TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            BusinessObjectControlStub boControl = (BusinessObjectControlStub)gridAndBOEditorControl.BusinessObjectControl;
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            BusinessObjectInfo firstBO = businessObjectInfos[0];
//            firstBO.BusinessObjectName = TestUtils.GetRandomString();
//            BusinessObjectInfo secondBO = businessObjectInfos[1];
//            //---------------Assert Precondition----------------
//            Assert.IsTrue(firstBO.Status.IsDirty);
//            Assert.IsFalse(firstBO.Status.IsNew);
//            Assert.IsFalse(secondBO.Status.IsDirty);
//            Assert.IsFalse(secondBO.Status.IsNew);
//            Assert.AreEqual(0, gridAndBOEditorControl.ReadOnlyGridControl.Grid.SelectedRows[0].Index);
//            Assert.AreSame(firstBO, gridAndBOEditorControl.ReadOnlyGridControl.Grid.SelectedBusinessObject);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.ReadOnlyGridControl.Grid.SelectedBusinessObject = secondBO;
//            //---------------Test Result -----------------------
//            Assert.AreEqual(1, gridAndBOEditorControl.ReadOnlyGridControl.Grid.SelectedRows[0].Index);
//            Assert.AreSame(secondBO, gridAndBOEditorControl.ReadOnlyGridControl.Grid.SelectedBusinessObject);
//            Assert.IsFalse(firstBO.Status.IsDirty);
//            Assert.IsFalse(boControl.DisplayErrorsCalled);
//        }

//        [Test]
//        public void Test_CannotClickNewButtonIfCurrentObjectInvalid()
//        {
//            //---------------Set up test pack-------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            BusinessObjectControlStub boControl = (BusinessObjectControlStub)gridAndBOEditorControl.BusinessObjectControl;
//            gridAndBOEditorControl.SetBusinessObjectCollection(new BusinessObjectCollection<BusinessObjectInfo>());
//            IButton newButton = gridAndBOEditorControl.Buttons["New"];
//            newButton.PerformClick();
//            BusinessObjectInfo currentBO = (BusinessObjectInfo)gridAndBOEditorControl.BusinessObjectControl.BusinessObject;
//            //---------------Assert Precondition----------------
//            Assert.IsFalse(currentBO.IsValid());
//            Assert.IsFalse(boControl.DisplayErrorsCalled);
//            //---------------Execute Test ----------------------
//            newButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.AreSame(currentBO, gridAndBOEditorControl.BusinessObjectControl.BusinessObject);
//            Assert.AreEqual(1, gridAndBOEditorControl.ReadOnlyGridControl.Grid.Rows.Count);
//            Assert.IsTrue(boControl.DisplayErrorsCalled);
//        }

//        [Test]
//        public void Test_CannotChangeGridRowIfCurrentObjectInvalid()
//        {
//            //---------------Set up test pack-------------------
//            BusinessObjectCollection<BusinessObjectInfo> businessObjectInfos = TestUtils.CreateSavedBusinessObjectInfosCollection();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            BusinessObjectControlStub boControl = (BusinessObjectControlStub) gridAndBOEditorControl.BusinessObjectControl;
//            gridAndBOEditorControl.SetBusinessObjectCollection(businessObjectInfos);
//            BusinessObjectInfo firstBO = businessObjectInfos[0];
//            firstBO.BusinessObjectName = null;
//            BusinessObjectInfo secondBO = businessObjectInfos[1];
//            //---------------Assert Precondition----------------
//            Assert.IsTrue(firstBO.Status.IsDirty);
//            Assert.IsFalse(firstBO.Status.IsNew);
//            Assert.IsFalse(firstBO.IsValid());
//            Assert.AreEqual(0, gridAndBOEditorControl.ReadOnlyGridControl.Grid.SelectedRows[0].Index);
//            Assert.AreSame(firstBO, gridAndBOEditorControl.ReadOnlyGridControl.Grid.SelectedBusinessObject);
//            Assert.IsFalse(boControl.DisplayErrorsCalled);
//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.ReadOnlyGridControl.Grid.SelectedBusinessObject = secondBO;
//            //---------------Test Result -----------------------
//            Assert.AreEqual(0, gridAndBOEditorControl.ReadOnlyGridControl.Grid.SelectedRows[0].Index);
//            Assert.AreSame(firstBO, gridAndBOEditorControl.ReadOnlyGridControl.Grid.SelectedBusinessObject);
//            Assert.IsTrue(firstBO.Status.IsDirty);
//            Assert.IsTrue(boControl.DisplayErrorsCalled);
//        }

//        [Test]
//        public void Test_DisplayErrorsNotCalledWhenNewButtonClicked()
//        {
//            //---------------Set up test pack-------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            BusinessObjectControlStub boControl = (BusinessObjectControlStub)gridAndBOEditorControl.BusinessObjectControl;
//            gridAndBOEditorControl.SetBusinessObjectCollection(new BusinessObjectCollection<BusinessObjectInfo>());
//            IButton newButton = gridAndBOEditorControl.Buttons["New"];
//            //---------------Assert Precondition----------------
//            Assert.IsFalse(boControl.DisplayErrorsCalled);
//            //---------------Execute Test ----------------------
//            newButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.IsFalse(boControl.DisplayErrorsCalled);
//        }

//        [Test]
//        public void Test_ClearErrorsWhenNewObjectAdded()
//        {
//            //---------------Set up test pack-------------------
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            BusinessObjectControlStub boControl = (BusinessObjectControlStub)gridAndBOEditorControl.BusinessObjectControl;
//            gridAndBOEditorControl.SetBusinessObjectCollection(new BusinessObjectCollection<BusinessObjectInfo>());
//            IButton newButton = gridAndBOEditorControl.Buttons["New"];
//            //---------------Assert Precondition----------------
//            Assert.IsFalse(boControl.ClearErrorsCalled);
//            //---------------Execute Test ----------------------
//            newButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.IsTrue(boControl.ClearErrorsCalled);
//        }

//        [Test]
//        public void Test_ParentPropsSetWhenCreatingNewObject()
//        {
//            //---------------Set up test pack-------------------
//            ProjectInfo projectInfo = TestUtils.CreateSavedProjectInfo();
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(projectInfo.BusinessObjectInfos);
//            IButton newButton = gridAndBOEditorControl.Buttons["New"];
//            //---------------Assert Precondition----------------

//            //---------------Execute Test ----------------------
//            newButton.PerformClick();
//            //---------------Test Result -----------------------
//            Assert.AreEqual(projectInfo.ProjectInfoID, gridAndBOEditorControl.CurrentBusinessObject.ProjectInfoID);
//        }

//        [Test]
//        public void TestBusinessObjectSelectedEvent()
//        {
//            //---------------Set up test pack-------------------
//            ProjectInfo projectInfo = TestUtils.CreateSavedBusinessObjectInfo().Project;
//            GridAndBOEditorControl<BusinessObjectInfo> gridAndBOEditorControl = CreateGridAndBOEditorControl();
//            gridAndBOEditorControl.SetBusinessObjectCollection(projectInfo.BusinessObjectInfos);
//            bool fired = false;
//            BusinessObjectInfo selectedInfo = null;

//            //---------------Execute Test ----------------------
//            gridAndBOEditorControl.BusinessObjectSelected += 
//                (sender, e) => {
//                        fired = true;
//                        selectedInfo = e.BusinessObject;
//                    };
//            gridAndBOEditorControl.CurrentBusinessObject = projectInfo.BusinessObjectInfos[0];
//            //---------------Test Result -----------------------

//            Assert.IsTrue(fired);
//            Assert.AreSame(selectedInfo, gridAndBOEditorControl.CurrentBusinessObject);
//            //---------------Tear Down -------------------------          
//        }
//    }

//    internal class BusinessObjectControlStub : UserControlWin, IBusinessObjectControlWithErrorDisplay
//    {
//        private IBusinessObject _businessObject;
//        private bool _displayErrorsCalled;
//        private bool _clearErrorsCalled;

//        public bool DisplayErrorsCalled
//        {
//            get { return _displayErrorsCalled; }
//        }

//        public bool ClearErrorsCalled
//        {
//            get { return _clearErrorsCalled; }
//        }

//        public IBusinessObject BusinessObject
//        {
//            get { return _businessObject; }
//            set { _businessObject = value; }
//        }

//        public void DisplayErrors()
//        {
//            _displayErrorsCalled = true;
//        }

//        public void ClearErrors()
//        {
//            _clearErrorsCalled = true;
//        }
//    }
//}